import CommonApi from './common'
// 登录用户相关
class UserApi extends CommonApi {
    constructor() {
        super()
        this.scope = '/user'
    }

    resolvePath(path) {
        return this.scope + path
    }

    // 退出登录注销token
    logout(data) {
        const path = '/has/auth/token/delete'
        return this.post(path, data, { baseURL: '' })
    }

    // 登录之后获取对应的应用列表
    loadSystems(data) {
        const path = '/has/user/userinfo/linkApp'
        return this.post(path, data, { baseURL: ''})
    }
    // 获取系统下载地址
    getDownloadUrl(data) {
        const path = '/has/user/console/get-package'
        return this.post(path, data, { baseURL: ''})
    }
    // 获取has用户信息，用户处理收费系统跳转判断
    getHasUserInfo() {
        const path = '/has/user/userinfo/showUserInfo'
        return this.post(path, {}, { baseURL: ''})
    }

    login(data) {
        const path = this.resolvePath('/login')
        return this.post(path, data)
    }

    updateTest(data) {
        const path = this.resolvePath('/test')
        return this.patch(path, data)
    }

    changePassword(data) {
        const path = this.resolvePath('/change-password')
        return this.post(path, data)
    }

    queryRoutes(data) {
        const path = this.resolvePath('/add-user')
        return this.post(path, data)
    }

    // logout() {
    //     const path = this.resolvePath('/logout')
    //     return this.get(path)
    // }

    loadInfo(params) {
        const path = this.resolvePath('/getUserInfo')
        return this.post(path, params)
    }

    usersByUserCenter({ page, per, ...args }) {
        const path = this.resolvePath(`/select/sysUser/${page}/${per}`)
        return this.post(path, args)
    }

    departmentPath(page, per) {
        const path = this.resolvePath(`/select/sysDept/${page}/${per}`)
        return path
    }

    arePath(page, per) {
        const path = this.resolvePath(`/select/sysRegion/${page}/${per}`)
        return path
    }

    // 分页区域路段
    areListPath(page, per) {
        const path = this.resolvePath(
            `/select/sysRegionRangeLink/showPage/${page}/${per}`
        )
        return path
    }

    // 查询人员所属机构所有下级或上级人员信息
    getDepartUserInfo(data) {
        const path = this.resolvePath('/getDepartUserInfo')
        return this.post(path, data)
    }
    // 获取用户所属管理处及管理处下级机构及用户
    getManageSubDeparts(data) {
        const path = '/dept/subs'
        return this.post(path, data)
    }
}

export default UserApi
